﻿<div style="background:#fbf9fe" ms-controller="GJJL">
    <div ms-if="isHasDataQX=='Y'">
        <!--<div class="weui_cells_title">基本信息</div>-->
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell" style="display:none;">
                <div class="weui_cell_hd"><label class="weui_label label">客户</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <!--<select ms-duplex="htmodel.KHID" class="weui-select szhl szhl_require" id="gjkhid">
                        <option ms-repeat-item="ColumnData" ms-attr-value="item.ID" ms-attr-selected="item.ID==htmodel.KHID?'selected':''">{{item.KHName}}</option>
                    </select>-->
                    <input type="text" id="conKH" placeholder="请选择对应客户" ms-duplex="modelData.KHID" class="szhl szhl_getKH single weui_input" />
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">状态</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <select ms-duplex="htmodel.HTStatus" class="weui-select">
                        <option ms-repeat-item="ColumnData1" ms-attr-value="item.ID" ms-attr-selected="item.ID==modelData.Status?'selected':''">{{item.TypeName}}</option>
                    </select>
                </div>
            </div>
            
        </div>
        <div class="weui_cells_title">描述</div>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_hd" style="display:none;"><label class="weui_label label">描述</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <textarea ms-duplex="modelData.Details" rows="3" placeholder="请输入描述" class="weui_textarea szhl szhl_require"></textarea>
                </div>
            </div>
        </div>
        <div class="weui_cells_title">图片上传</div>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <input type="text" ms-duplex="modelData.Files" class="wximgupload" style="display:none;" />
                </div>
            </div>
        </div>
    </div>
    <div ms-if="isHasDataQX=='N'">
        <!--<div class="weui_cells_title">基本信息</div>-->
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell" style="display:none;">
                <div class="weui_cell_hd"><label class="weui_label label">客户</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    {{khname}}
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">状态</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    {{gjzt}}
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label label">方式</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    {{modelData.Type}}
                </div>
            </div>
        </div>
        <div class="weui_cells_title">描述</div>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    {{modelData.Details|html}}
                </div>
            </div>
        </div>
        <div class="weui_cells_title">图片上传</div>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <div class="viewimg">{{modelData.Files}}</div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    var tempmodel = avalon.define({
        $id: "GJJL",
        ColumnData: [],
        ColumnData1: [],
        name: "跟进记录管理",
        tpData: [],
        wximg: "",
        dataid: "",
        khname: "",
        gjzt: "",
        istx: "N",
        htmodel: {},
        htid: ComFunJS.getQueryString("htid"),
        isTX: function (dom) {
            if ($(dom).prop("checked")) {
                tempmodel.modelData.IsTX = "Y";
                tempmodel.istx = 'Y';
            }
            else {
                tempmodel.modelData.IsTX = "N";
                tempmodel.istx = 'N';
            }
        },
        inittemp: function (strId) {
            tempmodel.ColumnData1 = [{ "ID": "0", "TypeName": "未开始" }, { "ID": "1", "TypeName": "执行中" }, { "ID": "2", "TypeName": "成功结束" }, { "ID": "3", "TypeName": "意外终止" }];


            $.getJSON('/API/VIEWAPI.ashx?Action=CRM_GETHTMODEL', { P1: tempmodel.htid }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    tempmodel.htmodel = resultData.Result;

                    if (!tempmodel.htmodel.HTStatus) {
                        tempmodel.htmodel.HTStatus = 0;
                    }
                }
            })

            if (strId) {

                tempmodel.dataid = strId;
                $.getJSON('/API/VIEWAPI.ashx?Action=CRM_GETGJJLMODEL', { P1: strId }, function (resultData) {

                    if (resultData.ErrorMsg == "") {
                        tempmodel.modelData = resultData.Result;


                        ComFunJS.uploadimgnew(tempmodel.tpData);
                        ComFunJS.viewimg(tempmodel.tpData);

                        setTimeout(" ComFunJS.initForm()", 500)
                    }
                })
            } else {
                $("#appDate").calendar({
                    value: []
                });

                ComFunJS.uploadimgnew();
                ComFunJS.initForm();
            }
        },//初始化
        modelData: { "KHID": "", "Status": "", "Date": "", "Details": "", "Type": "", "IsTX": "N", "TXDate": "", "Remark": "", "CYUser": "", "Files": "" },
        SaveData: function (callback) {

            tempmodel.modelData.Files = "";
            $("#imglist .tpli").each(function () {
                if ($(this).hasClass("wximg")) { //微信上传未处理的图片
                    if (tempmodel.wximg) {
                        tempmodel.wximg += ",";
                    }
                    tempmodel.wximg += $(this).attr("itemid");

                } else {
                    if (tempmodel.modelData.Files) {
                        tempmodel.modelData.Files = tempmodel.modelData.Files + ',' + $(this).attr("itemid");
                    }
                    else {
                        tempmodel.modelData.Files = $(this).attr("itemid");
                    }
                }
            })

            tempmodel.modelData.KHID = tempmodel.htmodel.ID;
            tempmodel.modelData.Status = tempmodel.htmodel.HTStatus;
            tempmodel.modelData.Remark = tempmodel.htmodel.KHID;

            $.getJSON("/API/VIEWAPI.ashx?ACTION=CRM_ADDGJJL", { P1: JSON.stringify(tempmodel.modelData.$model), P2: tempmodel.wximg, "gjtype": "HTGL" }, function (result) {
                return callback.call(this, result);
            });
        },
        Complate: function () {
            window.location.href = "/View_Mobile/UI/CRM/UI_HTGL_LIST.html?r=" + Math.random();
        }
    });//# sourceURL=MHYGL.js;

</script>